#pragma once

#include <muduo/net/TcpServer.h>
#include <muduo/net/EventLoop.h>
using namespace muduo;
using namespace muduo::net;

/////////////////////////////////////////////////////////////////////////////////////////////
/*

    ChatServer是一个实现聊天服务器的类
    
*/
class ChatServer
{
public:
    ChatServer(EventLoop* loop,
               const InetAddress& listenAddr,
               const string& nameArg);
    /*············································

              设置给Server的阶段性回调函数
    
    ············································*/
    void OnConnection(const TcpConnectionPtr&);
    void OnMessage(const TcpConnectionPtr&, Buffer *buffer, Timestamp time);
    /*············································

                    开始运行服务器
    
    ············································*/
    void Start();
private:
    TcpServer _server;
    EventLoop* _loop;
};